/**
 * 节流
 *
 * @param {Function} func
 * @param {Number} delay
 * @returns Function
 */
export function useThrottle(func, delay = 1000) {
  let timer = null;
  return function () {
    if (timer !== null) {
      return;
    }

    timer = setTimeout(() => {
      func.apply(this, arguments);
      timer = null;
    }, delay);
  };
}
